package com.ruoyi.project.msgBzk.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.msgBzk.domain.MsgSsjBzk;
import com.ruoyi.project.msgBzk.service.IMsgSsjBzkService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 托盘库（监控）Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@Controller
@RequestMapping("/system/bzk")
public class MsgSsjBzkController extends BaseController
{
    private String prefix = "system/bzk";

    @Autowired
    private IMsgSsjBzkService msgSsjBzkService;

    @GetMapping()
    public String bzk()
    {
        return prefix + "/bzk";
    }

    /**
     * 查询托盘库（监控）列表
     */
    @RequiresPermissions("system:bzk:list")
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(MsgSsjBzk msgSsjBzk)
    {
//        startPage();
        List<MsgSsjBzk> list = msgSsjBzkService.selectMsgSsjBzkList(msgSsjBzk);
        return getDataTable(list);
    }

    /**
     * 导出托盘库（监控）列表
     */
    @RequiresPermissions("system:bzk:export")
    @Log(title = "托盘库（监控）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MsgSsjBzk msgSsjBzk)
    {
        List<MsgSsjBzk> list = msgSsjBzkService.selectMsgSsjBzkList(msgSsjBzk);
        ExcelUtil<MsgSsjBzk> util = new ExcelUtil<MsgSsjBzk>(MsgSsjBzk.class);
        return util.exportExcel(list, "托盘库（监控）数据");
    }

    /**
     * 新增托盘库（监控）
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存托盘库（监控）
     */
    @RequiresPermissions("system:bzk:add")
    @Log(title = "托盘库（监控）", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MsgSsjBzk msgSsjBzk)
    {
        return toAjax(msgSsjBzkService.insertMsgSsjBzk(msgSsjBzk));
    }

    /**
     * 修改托盘库（监控）
     */
    @RequiresPermissions("system:bzk:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        MsgSsjBzk msgSsjBzk = msgSsjBzkService.selectMsgSsjBzkById(id);
        mmap.put("msgSsjBzk", msgSsjBzk);
        return prefix + "/edit";
    }

    /**
     * 修改保存托盘库（监控）
     */
    @RequiresPermissions("system:bzk:edit")
    @Log(title = "托盘库（监控）", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MsgSsjBzk msgSsjBzk)
    {
        return toAjax(msgSsjBzkService.updateMsgSsjBzk(msgSsjBzk));
    }

    /**
     * 删除托盘库（监控）
     */
    @RequiresPermissions("system:bzk:remove")
    @Log(title = "托盘库（监控）", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(msgSsjBzkService.deleteMsgSsjBzkByIds(ids));
    }
}
